package cn.fay.chapter13;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Groups {

	public static final String POEM="Twas brillig, and the slithy toves\n"+
			"Dig gyre and gimble in the wabe.\n"+"All mimsy were the borogoves,\n"+
			"And the more raths outgrabe.\n\n"+
			"The jaws that bite, the claws that catch.\n"+
			"Beware the Jubjub bird, and shun\n"+
			"The frumious Bandersnatch.";
	public static void main(String[] args) {
		
		Matcher m=Pattern.compile("(?m)(\\S+)\\s+((\\S+)\\s+(\\S+))$").matcher(POEM);
		Pattern pattern = Pattern.compile("\\w");
		while (m.find()) {
			for (int j=0;j<=m.groupCount();j++){
				System.out.println("["+m.group()+"]");
			}
		}
	}

}
